/* Autostop
 *
 * Copyright (c) Maciej Gajewski, Grzegorz Latarowski
 * http://code.google.com/p/autostop-automaty-drogowe
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version. NO WARRANTY OF ANY KIND is expressed or implied.
 */

#ifndef SERVERLISTENER_H
#define SERVERLISTENER_H

// Qt
#include <QTcpServer>

// local
#include "serverthread.h"
#include "constants.h"



// ---------------------------- ServerListener{} -----------------------------
/// TCP Server listener class. Listens on tcp port,
/// spawns new thread on each incoming connection.
// ---------------------------------------------------------------------------
class ServerListener : protected QTcpServer
{
public:

	ServerListener( const quint8 serverType );
	virtual ~ServerListener();

	/// Listen for incoming connection infinitely (or unitl error)
	void listen( const QHostAddress & address = QHostAddress::Any, quint16 port = 0 );

protected:

	/// Handles incomng connection
	virtual void incomingConnection( int socket );

private:
	quint8 _serverType;
	
}; // class !ServerListener
// ---------------------------------------------------------------------------




#endif // !SERVERLISTENER_H

// eof 


